<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 14:04:56
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:08:37
-->
<template>
  <div class="details">

    <!-- 标题开始 -->
    <h2 class="title">{{data.name}}</h2>
    <!-- 标题结束 -->

    <!-- 项目详情开始 -->
    <div class="time">{{data.beginTime}}~{{data.endTime}}</div>
    <div class="wrapper" v-html="data.details"></div>
    <!-- 项目详情结束 -->

    <div class="btn">
      <el-button @click="toApply(data.id)">报名</el-button>
    </div>
  </div>
</template>

<script>
import {get} from '../utils/request'
export default {
  data(){
    return{
      id:'',
      data:{}
    }
  },
  methods:{
    //查询项目的详细信息
    findProjectDetails(){
      //数据交互
      get('/index/project/findById?id='+this.id).then(res=>{
        //console.log(res,'----------------');
        if(res.status==200){
          this.data=res.data
        }else{
          this.$message({
            type:'error',
            message:res.message
          })
        }
      })
    },
    
    //跳转到报名页面
    toApply(id){
      this.$router.push({path:'/apply',query:{id:id}})
    }
  },
  



  created(){
  //   //拿到从上一个页面传过来的id值
  //  var id= this.$route.query.id
  //  alert(id)

   this.id=this.$route.query.id

   //调用查询project详情的方法
   this.findProjectDetails()
  }
}
</script>

<style scoped lang='scss'>
.details{
  padding: 14px 0;
  .title{
    font-size: 20px;
    line-height: 3em;
    text-align: center;
    color: #333;
    font-weight: 700;
  }

  .time{
          margin: 1em 0;
          text-align: center;
        }

  .wrapper{
    width: 980px;
    //background-color: antiquewhite;
  }
  .btn{
    text-align: center;
    } 
}
  
</style>
